package algutil.parser;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

public class TableTag {

	private static final Logger log = Logger.getLogger(TableTag.class);

	private String text;

	private List<TRTag> trs;

	public TableTag(String s) {
		text = s;
		extractTR();
	}

	private void extractTR() {
		trs = new ArrayList<TRTag>();

		int pos = 0;
		while (pos != -1) {

			TRTag tr = new TRTag(text.substring(text.indexOf(">", text.indexOf(
					"<tr", pos)) + 1, text.indexOf("</tr>", pos)));
			log.debug(tr);
			tr.extractTD();
			trs.add(tr);

			pos = text.indexOf("<tr", text.indexOf("<tr", pos) + 1);

		}

	}

	public String toString() {
		return "TABLE : " + text;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public List<TRTag> getTrs() {
		return trs;
	}

	public void setTrs(List<TRTag> trs) {
		this.trs = trs;
	}
}
